# -------------------- # CodeSkulptor - Python Basics [Challenge 2] # [Challenge Prompt]: Write a Number Guesser game! # [Made by]: Kevin J. # -------------------- # [Date]: Tuesday, July 29, 2025 # -------------------- # Setup the environment for the number guesser game. import random validChoice = "False" # Setting the preliminary guess to -10 ensures the game won't autocomplete if the number happens to be exactly the same as the preliminary. guess = "-10" # Ask the user which mode they'd like to play. mode = input("What mode would you like to play (Easy/Hard)?") if mode == "Easy": validChoice = "True" elif mode == "Hard": validChoice = "True" elif mode == "easy": validChoice = "True" elif mode == "hard": validChoice = "True" else: validChoice = "False" while validChoice == "False": print("Invalid choice. The valid choices are [Easy] or [Hard].") print() mode = input("What mode would you like to play (Easy/Hard)?") if mode == "Easy": validChoice = "True" elif mode == "Hard": validChoice = "True" elif mode == "easy": validChoice = "True" elif mode == "hard": validChoice = "True" else: validChoice = "False" # Assign the variable "secretNumber" to a randomly generated number between 1 and 10 (1 to 100 for hard mode). if mode == "Easy" or mode == "easy": secret = random.randint(1, 10) range = "1 to 10" elif mode == "Hard" or mode == "hard": secret = random.randint(1, 100) range = "1 to 100" # Verify if the guess is equal to the secret number. while guess != secret: print("Guess a number between", range) guess = int(input("Take a guess: ")) if guess > secret: print("Your guess is too high; guess again.") print() elif guess < secret: print("Your guess is too low; guess again.") print() else: print("Correct! You guessed correctly! The secret number was:", secret)